#ifndef RAJA_TTF2_HWA_FONT_HPP
#define RAJA_TTF2_HWA_FONT_HPP

#include "sw_font.hpp"

namespace raja
{
	namespace ttf2
	{
		struct hw_font;

		typedef boost::shared_ptr<hw_font>	hw_font_ptr;

		struct hw_font
		{
			static	hw_font_ptr		create_instance(const ttf2::sw_font_ptr &font);

			math::vec2				draw_char(const math::vec2 &pos, uint8 ch) const;

			void					use_texture() const { glBindTexture(GL_TEXTURE_2D, __texture_id); }

			real32					get_line_height() const { return __line_height; }

			real32					get_char_width(uint8 ch) const
			{
				return __chars[ch - ttf2::sw_font::CHAR_START].bbox_max.x - __chars[ch - ttf2::sw_font::CHAR_START].bbox_min.x;
			}

			real32					get_char_height(uint8 ch) const
			{
				return __chars[ch - ttf2::sw_font::CHAR_START].bbox_max.y - __chars[ch - ttf2::sw_font::CHAR_START].bbox_min.y;
			}

			real32					get_char_advance(uint8 ch) const { return __chars[ch - ttf2::sw_font::CHAR_START].advance; }

			~hw_font();

		private:
			hw_font() {}	///< don't let users use it!

			// this contains font information relative to GL texture coordinate system
			struct __hw_char
			{
				math::vec2			uv_min;
				math::vec2			uv_max;
				real32				advance;
				math::vec2			bbox_min;
				math::vec2			bbox_max;
			};

			std::vector<__hw_char>	__chars;

			real32					__line_height;

			uint32					__texture_id;
		};	// hwa_font

	} // namespace ttf2
} // namespace raja
#endif // RAJA_TTF2_HWA_FONT_HPP
